package servlet;

/**
 * Created by louisyuu on 2020/4/1 下午5:57
 */
public abstract class HttpServlet implements Servlet {


    public void init() throws Exception {

    }

    public void destroy() throws Exception {

    }


    protected abstract void doGet(Request request, Response response) throws Exception;

    protected abstract void doPost(Request request, Response response) throws Exception;


    public void service(Request request, Response response) throws Exception {

        if ("GET".equalsIgnoreCase(request.getMethod())) {
            doGet(request, response);
        } else {
            doPost(request, response);
        }

    }
}
